package com.summer.data.demo.controller;

import com.summer.data.demo.service.StudentService;
import com.summer.data.demo.service.TeacherService;
import com.summer.data.demo.tables.StudentTable;
import com.summer.data.rs.datatype.ObjectPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/teacher")
public class TeacherController {

    @Autowired
    StudentService studentService;

    @Autowired
    TeacherService teacherService;

    @GetMapping("/list")
    public List<StudentTable> list() {
        return studentService.listStudent();
    }

    @GetMapping("/page")
    public ObjectPage<StudentTable> page() {
        return studentService.pageStudent();
    }

    @GetMapping("/add")
    public Integer add() {
        return studentService.addStudent("stu_100", "张三");
    }

    @GetMapping("/update")
    public Integer update() {
        return studentService.updateStudent("stu_100", "李四");
    }

    @GetMapping("/del")
    public Integer del() {
        return studentService.delStudent("stu_100");
    }

}
